<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="org.edu.system.DBConnect" %>
<%@ page import="java.sql.*" %>
<%
	String tc_id = (String)(session.getAttribute("UserName"));
	String sql = "SELECT * FROM teacher WHERE tc_id = '" + tc_id + "'";
	System.out.println(sql);
	
	Connection con = DBConnect.getCon();
	Statement stmt = null;
	ResultSet rs = null;
	stmt = con.createStatement();
	rs = stmt.executeQuery(sql);//执行命令
	if (rs.next())// 如果记录集非空，表明有匹配的用户ID
	{
			//正常进行
	} else {
		// 否则登录失败
		// response.sendRedirect ( "MyJsp.jsp" );
		response.sendRedirect("login_failure.jsp");
	}
%>
<!DOCTYPE html>
<html>
<head>
<link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet">
<meta charset="utf-8">
<title>教师教务管理系统 - 成绩管理</title>
</head>
<body style="width:900px; margin:0 auto;">
<br>
<table border="1" width="100%" frame="hsides" style="text-align:center" class="table table-striped table-bordered">
		<tr>
			<th style="text-align:center">课程名</th>
			<th style="text-align:center">班级</th>
			<th style="text-align:center">录入状态</th>
			<th colspan="2" style="text-align:center">数据操作</th>
		</tr>
		<% 
			sql = "SELECT l.lesson_id,c.course_name,l.grade_status,l.class FROM lesson l,course c WHERE l.tc_id = '"+tc_id+"' and l.course_id = c.course_id";
			stmt = null;
			rs = null;
			stmt = con.createStatement();
			rs = stmt.executeQuery(sql);//执行命令
			while (rs.next())// 如果记录集非空，表明有匹配的用户ID
			{
				out.print("<tr>" 
					+ "<td>" + rs.getString("course_name") + "</td>" 
					+ "<td>" + rs.getString("class") + "</td>" 
					+ "<td>状态：" + rs.getString("grade_status") + "</td>");
				if(rs.getString("grade_status").equals("未录入"))
				{
					out.print("<td><input type=\"button\" class=\"btn btn-primary btn-xs\" value=\"录入成绩\" onclick=\"javawwscript:location='tea_inputGrade.jsp?lessonID="+rs.getString("lesson_id")+"'\"/></td>");
				}
				else
				{
					out.print("<td><input type=\"button\" class=\"btn btn-warning btn-xs\" value=\"修改成绩\" onclick=\"javawwscript:if(confirm('确认修改成绩？')){location='tea_inputGrade.jsp?lessonID="+rs.getString("lesson_id")+"'}\"/></td>");
					out.print("<td><input type=\"button\" class=\"btn btn-success btn-xs\" value=\"打印成绩\" onclick=\"javawwscript:if(confirm('确认打印成绩？')){location='ExportGrade.jsp?lessonID="+rs.getString("lesson_id")+"'}\"/></td>");
				}
				out.print("</tr>");
			} 
		%>
</table>
</body>
</html>